package com.atguigu.gmall.user.service.impl;


import com.atguigu.gmall.common.util.MD5;
import com.atguigu.gmall.model.user.UserInfo;
import com.atguigu.gmall.user.mapper.UserInfoMapper;
import com.atguigu.gmall.user.service.UserService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
@Transactional
public class UserServiceImpl implements UserService {

    @Autowired
    private UserInfoMapper userInfoMappper;

    //校验用户名密码
    @Override
    public UserInfo login(UserInfo userInfo) {
        //注册   自己弄




        //查询数据库是否有此用户  并且 密码还要正确
        UserInfo userInfo1 = userInfoMappper.selectOne(
                new QueryWrapper<UserInfo>()
                .eq("login_name", userInfo.getLoginName())
                .eq("passwd", MD5.encrypt(userInfo.getPasswd())));

        return userInfo1;
    }

    public static void main(String[] args) {
        System.out.println(MD5.encrypt("123"));
    }
}
